package com.geolab.service.impl;

import com.geolab.pojo.ResponseResult;
import com.geolab.pojo.clay.*;
import com.geolab.pojo.sand.SandLoadTestRecords;
import com.geolab.pojo.sand.SandLoadTestResults;
import com.geolab.pojo.sand.SandSleeveFriction;
import com.geolab.pojo.sand.SandTipResistance;
import com.geolab.service.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResponseResultServiceImpl implements ResponseResultService {

    @Autowired
    private SandLoadTestRecordsService sandLoadTestRecordsService;
    @Autowired
    private PileLoadTestRecordsService pileLoadTestRecordsService;
    @Autowired
    private SandExtraDataService sandExtraDataService;
    @Autowired
    private ClayExtraDataService clayExtraDataService;

    @Override
    public ResponseResult<List<SandLoadTestRecords>> selectSandAllRecords() {
        ResponseResult<List<SandLoadTestRecords>> result = null;
        List<SandLoadTestRecords> data = sandLoadTestRecordsService.selectSandAllRecords();
        if (data.size() > 0){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<SandLoadTestRecords>> selectSandRecordsByPage(int pageId) {
        ResponseResult<List<SandLoadTestRecords>> result = null;
        List<SandLoadTestRecords> data = sandLoadTestRecordsService.selectSandRecordsByPage(pageId);
        if (data.size() > 0){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<PageInfo<SandLoadTestRecords>> selectSandAllRecordsByPageHelper() {
        ResponseResult<PageInfo<SandLoadTestRecords>> result = null;
        PageHelper.startPage(1,20);
        List<SandLoadTestRecords> data = sandLoadTestRecordsService.selectSandAllRecords();
        PageInfo<SandLoadTestRecords> pageInfo = new PageInfo<>(data);
        if (data.size() > 0){
            result = new ResponseResult<>(true,"查询成功，每页20个数据",pageInfo);
        }else {
            result = new ResponseResult<>(false,"查询失败",pageInfo);
        }
            return result;
    }

    @Override
    public ResponseResult<SandLoadTestRecords> selectSandById(int ID) {
        ResponseResult<SandLoadTestRecords> result = null;
        SandLoadTestRecords data = sandLoadTestRecordsService.selectSandById(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<SandLoadTestRecords>> selectSandLike(String keyword) {
        ResponseResult<List<SandLoadTestRecords>> result = null;
        List<SandLoadTestRecords> data = sandLoadTestRecordsService.selectSandLike(keyword);
        if (data.size() > 0){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败",data);
        }
        return result;
    }

    @Override
    public ResponseResult<Integer> countSandRecords() {
        int data = sandLoadTestRecordsService.countSandRecords();
        return new ResponseResult<>(true,"查询成功",data);
    }

    @Override
    public ResponseResult<List<PileLoadTestRecords>> selectClayAllRecords() {
        ResponseResult<List<PileLoadTestRecords>> result = null;
        List<PileLoadTestRecords> data = pileLoadTestRecordsService.selectClayAllRecords();
        if (data.size() > 0){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<PileLoadTestRecords>> selectClayRecordsByPage(int pageId) {
        ResponseResult<List<PileLoadTestRecords>> result = null;
        List<PileLoadTestRecords> data = pileLoadTestRecordsService.selectClayRecordsByPage(pageId);
        if (data.size() > 0){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<PageInfo<PileLoadTestRecords>> selectClayAllRecordsByPageHelper() {
        ResponseResult<PageInfo<PileLoadTestRecords>> result = null;
        PageHelper.startPage(1,20);
        List<PileLoadTestRecords> data = pileLoadTestRecordsService.selectClayAllRecords();
        PageInfo<PileLoadTestRecords> pageInfo = new PageInfo<>(data);
        if (data.size() > 0){
            result = new ResponseResult<>(true,"查询成功，每页20个数据",pageInfo);
        }else {
            result = new ResponseResult<>(false,"查询失败",pageInfo);
        }
        return result;
    }

    @Override
    public ResponseResult<PileLoadTestRecords> selectClayById(int ID) {
        ResponseResult<PileLoadTestRecords> result = null;
        PileLoadTestRecords data = pileLoadTestRecordsService.selectClayById(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<PileLoadTestRecords>> selectClayLike(String keyword) {
        ResponseResult<List<PileLoadTestRecords>> result = null;
        List<PileLoadTestRecords> data = pileLoadTestRecordsService.selectClayLike(keyword);
        if (data.size() > 0){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败",data);
        }
        return result;
    }

    @Override
    public ResponseResult<Integer> countClayRecords() {
        int data = pileLoadTestRecordsService.countClayRecords();
        return new ResponseResult<>(true,"查询成功",data);
    }

    @Override
    public ResponseResult<List<SandTipResistance>> querySandQcById(int ID) {
        ResponseResult<List<SandTipResistance>> result = null;
        List<SandTipResistance> data = sandExtraDataService.selectSandQcById(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<SandSleeveFriction>> querySandFsById(int ID) {
        ResponseResult<List<SandSleeveFriction>> result = null;
        List<SandSleeveFriction> data = sandExtraDataService.selectSandFsById(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<SandLoadTestResults>> querySandLoadResultsById(int ID) {
        ResponseResult<List<SandLoadTestResults>> result = null;
        List<SandLoadTestResults> data = sandExtraDataService.selectSandLoadResultsById(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<LL>> queryClayLLById(int ID) {
        ResponseResult<List<LL>> result = null;
        List<LL> data = clayExtraDataService.selectClayLLById(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<LoadTestResults>> queryClayLoadByID(int ID) {
        ResponseResult<List<LoadTestResults>> result = null;
        List<LoadTestResults> data = clayExtraDataService.selectClayLoadByID(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<PL>> queryClayPLByID(int ID) {
        ResponseResult<List<PL>> result = null;
        List<PL> data = clayExtraDataService.selectClayPLByID(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<SoilDetail> queryClayDetailByID(int ID) {
        ResponseResult<SoilDetail> result = null;
        SoilDetail data = clayExtraDataService.selectClayDetailByID(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<Su>> queryClaySuByID(int ID) {
        ResponseResult<List<Su>> result = null;
        List<Su> data = clayExtraDataService.selectClaySuByID(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<TipResistance>> queryClayQcByID(int ID) {
        ResponseResult<List<TipResistance>> result = null;
        List<TipResistance> data = clayExtraDataService.selectClayQcByID(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<w>> queryClayWaterByID(int ID) {
        ResponseResult<List<w>> result = null;
        List<w> data = clayExtraDataService.selectClayWaterByID(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

    @Override
    public ResponseResult<List<γ>> queryClayWeightByID(int ID) {
        ResponseResult<List<γ>> result = null;
        List<γ> data = clayExtraDataService.selectClayWeightByID(ID);
        if (data != null){
            result = new ResponseResult<>(true,"查询成功",data);
        }else {
            result = new ResponseResult<>(false,"查询失败,超出数据库范围,请检查输入参数",data);
        }
        return result;
    }

}
